package com.example.fragment;

import java.util.ArrayList;

import com.example.androidtest.ImageThread;
import com.example.androidtest.MyFragmentAdapter;
import com.example.androidtest.R;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class Thing_Fragment extends Fragment {
	private ViewPager viewpager;
	private ArrayList<Fragment> data;
	private MyFragmentAdapter adapter;
	private FragmentManager fm;
	private TextView tv_thing;
	private ImageView im_thing;
	private Handler handler;
	private String result;
	private Bitmap bitmap;
	private String url="http://img0.imgtn.bdimg.com/it/u=3965306929,1867766385&fm=21&gp=0.jpg";

	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.fragment_things, null);
		im_thing = (ImageView) view.findViewById(R.id.im_thing);
//		tv_thing = (TextView) view.findViewById(R.id.tv_thing);
		handler = new Handler(new Handler.Callback() {

			@Override
			public boolean handleMessage(Message msg) {
				if (msg.what == 200) {
					bitmap =  (Bitmap) msg.obj;
					
				}
				im_thing.setImageBitmap(bitmap);
//				tv_thing.setText(result);
				return false;
			}
		});
		new ImageThread(handler, url).start();
		// viewpager = (ViewPager) view.findViewById(R.id.viewpager1);
		// data = new ArrayList<>();
		// data.add(new Home_Fragment());
		// data.add(new Home_Fragment());
		// data.add(new Home_Fragment());
		// data.add(new Home_Fragment());
		// adapter = new
		// MyFragmentAdapter(getActivity().getSupportFragmentManager(), data);
		// viewpager.setAdapter(adapter);
		return view;
	}
}
